#include <stdio.h>
#include <stdlib.h>

//https://leetcode.cn/problems/master-mind-lcci/

int compareChar(const void *A, const void *B) {
    return *(char *) A - *(char *) B;
}

int *masterMind(char *solution, char *guess, int *returnSize) {
    int *rets = (int *) calloc(2 ,sizeof(int));
    *returnSize = 2;
    for (int i = 0; i < 4; i++) {
        if (solution[i] == guess[i]) {
            rets[0]++;
        }
    }

    qsort(solution, 4, sizeof(char), compareChar);
    qsort(guess, 4, sizeof(char), compareChar);

    int solutionSize = 0;
    int guessSize = 0;
    while (solutionSize < 4 && guessSize < 4) {
        if (solution[solutionSize] == guess[guessSize]) {
            solutionSize++;
            guessSize++;
            rets[1]++;
        } else if (solution[solutionSize] > guess[guessSize]) {
            guessSize++;
        } else if (solution[solutionSize] < guess[guessSize]) {
            solutionSize++;
        }
    }
    rets[1] -= rets[0];
    return rets;
}

int main() {

    return 0;
}